﻿using MVC_Project.Dal.Systems;
using MVC_Project.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace MVC_Project.Bll.Systems
{
    public class DeptsBll:BaseBll<Department>
    {
        public override void SetDal()
        {
            Dal = new DeptsDal();
        }

        public List<Department> GetDepartmentPage(int page, int size, string name, out int count)
        {

            var users = Dal.Query();

            if (!string.IsNullOrWhiteSpace(name))
            {
                users = users.Where(u => u.deptName.Contains(name));
            }

            count = users.Count();

            var list = users.OrderBy(u => u.deptID).Skip((page - 1) * size).Take(size).ToList();

            return list;
        }

        
    }
}
